﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="ListUWork.aspx.cs" Inherits="cebao.Web.userinfo.ListUWork" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../CSS/IconExtension.css" rel="stylesheet" />
    <style type="text/css">
        #mymap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }

        .fite {
            margin-left: 4px;
        }

            .fite label {
                width: 100px;
                float: left;
                line-height: 35px;
            }
    </style>

    <script type="text/javascript">
        var sprovince = "";
        var scity = "";
        var scounty = "";
        var level;
        $.extend($.fn.tree.methods, {
            getLevel: function (jq, target) {
                var l = $(target).parentsUntil("ul.tree", "ul");
                return l.length + 1;
            }
        });
        var pt;
        var uid = "";
        var map;
        var data_info;
        var opts;
        $(function () {
            $.ajax({
                type: "post",
                dataType: "json",
                url: "../admin/getinfo.ashx?action=level",
                success: function aa(data) {
                    level = data[0].level;
                    if (level == -1) level = 3;
                    if (level <= 3)
                        sprovince = data[0].province;
                    if (level <= 2)
                        scity = data[0].city;
                    if (level <= 1)
                        scounty = data[0].county;

                }
            });
            var curr_time = new Date();
            var strDate = curr_time.getFullYear() + "-";
            strDate += curr_time.getMonth() + 1 + "-";
            strDate += curr_time.getDate();
            $("#datetime").datebox("setValue", strDate);
            InitTree();           
            InitGird();


        });

        function getQueryParams(queryParams) {
            var utype = $("#utype").combobox('getValue');
            var uname = $("#uname").val();
            var utruename = $("#utruename").val();            
            var datetime = $("#datetime").datebox('getValue');            
            queryParams.uname = uname;           
            queryParams.datetime = datetime;
            queryParams.utruename = utruename;
            queryParams.uprovince = sprovince;
            queryParams.ucity = scity;
            queryParams.ucounty = scounty;
            queryParams.utype = utype;
            return queryParams;

        }
        //增加查询参数，重新加载表格  
        function reloadgrid(t) {
            if (t != "" && t!=null) $("#utype").combobox('setValue',t);
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');
        }

        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '工作监管列表', //表格标题
                url: 'GetUser.ashx', //请求数据的页面
                sortName: 'datetime', //排序字段
                idField: 'uid', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '95%', //宽度
                height: '95%', //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                //sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect:false,
                method: 'post',
                columns: [[
                    { field: 'ckb', checkbox: true },
	                { title: '用户名', field: 'uname', width: 80, sortable: true },
                    {
                        title: '是否上传数据', field: 'datetime', width: 80, formatter: function (value, row, index) {
                            if (value == "")
                                return '<img src="/images/bullet_red.png" height="16" width="16"/>';
                            else
                                return '<img src="/images/bullet_green.png" height="16" width="16" />';
                        }
                    },
                    { title: '测报站名称', field: 'uunit', width: 150 },
                    { title: '联系电话', field: 'utel', width: 100 },
                    { title: '单位邮箱', field: 'uemail', width: 150 },
                    { title: '负责人姓名', field: 'utruename', width: 80 },
                    { title: '手机', field: 'uphone', width: 80 },
                    {
                        title: '提醒', field: 'u', width: 100, formatter: function (value, row, index) {
                            if (row.datetime == "") {                                
                                return '<img src="../CSS/IconsExtension/phone.png" onclick="sendmsg(' + row.uphone + ')" /> <img src="../CSS/IconsExtension/email.png" onclick="sendmail(' + row.uid + ')" />';
                                
                            }

                        }
                    }
                ]],
                onLoadSuccess: function (data) {
                    $('#tt').datagrid('fixRowHeight');
                },
                toolbar: "#tab_toolbar",
                queryParams: { "action": "querywork","datetime":$("#datetime").datebox('getValue') },
                pageNumber: 1, //默认索引页
                pageSize: 200, //默认一页数据条数
                rownumbers: true, //行号
                pageList: [10, 20, 50, 200, 500],
                pagination: true
            });
        }
        function sendmail(phone)
        {
            var date = $("#datetime").datebox('getValue');
            var msg = "您" + date + "的数据还没有上传请及时上传数据，以免耽误工作！";
            var title = "上传数据提醒";
            $('#fm').form('submit', {
                url: "../info/getinfo.ashx?action=addp&title=" + title + "&uid=" + suid + "&infocontent=" + msg,
                onSubmit: function () {
                    return $(this).form('validate');
                },
                success: function (result) {
                    if (result.indexOf("T") == 0) {
                        $.messager.alert("提示", "恭喜您，信息发送成功", "info");
                    }
                    else if ((result.indexOf("F") == 0)) {
                        $.messager.alert("提示", "发送失败，请重新操作！", "info");
                        return;
                    }
                    else if ((result.indexOf("L") == 0)) {
                        $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                        top.location = '/index.aspx';
                        return;
                    }
                }
            });

        }
        function sendmsg(suid)
        {
            $.messager.confirm('提示', '你确定要发送吗？', function (r) {
                if (r) {                    
                    var date = $("#datetime").datebox('getValue');
                    var msg = "您" + date + "的数据还没有上传请及时上传数据，以免耽误工作！";
                    var title = "上传数据提醒";
                    $('#fm').form('submit', {
                        url: "../info/getinfo.ashx?action=addph&title=" + title + "&uid=" + suid + "&infocontent=" + msg,
                        onSubmit: function () {
                            return $(this).form('validate');
                        },
                        success: function (result) {
                            if (result.indexOf("T") == 0) {
                                $.messager.alert("提示", "恭喜您，信息发送成功", "info");
                            }
                            else {
                                $.messager.alert("提示", result, "info");
                                return;
                            }
                        }
                    });

                }
            })
        }
        function getids(rows) {
            var ids = "";
            for (var i = 0; i < rows.length; i++)
                ids = ids + rows[i].uid + ",";
            if (ids != "")
                ids = ids.substr(0, ids.length - 1);
            return ids;

        }
        function getphs(rows) {
            var ids = "";
            for (var i = 0; i < rows.length; i++)
                ids = ids + rows[i].uphone + ",";
            if (ids != "")
                ids = ids.substr(0, ids.length - 1);
            return ids;

        }
        function sendmsgs() {
            var rows = $('#tt').datagrid('getSelections');
            if (rows == null || rows.length==0) {
                $.messager.alert("提示", "请选择要设置的行！", "info");
                return;
            }
            if (rows) {
                $.messager.confirm('提示', '你确定要发送吗？', function (r) {
                    if (r) {
                        var uids = getids(rows);
                        var date = $("#datetime").datebox('getValue');
                        var msg = "您" + date + "的数据还没有上传请及时上传数据，以免耽误工作！";
                        var title = "上传数据提醒";
                        $('#fm').form('submit', {
                            url: "../info/getinfo.ashx?action=adds&title=" + title + "&uid=" +uids + "&infocontent=" + msg,
                            onSubmit: function () {
                                return $(this).form('validate');
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $.messager.alert("提示", "恭喜您，信息发送成功", "info");
                                }
                                else if ((result.indexOf("F") == 0)) {
                                    $.messager.alert("提示", "发送失败，请重新操作！", "info");
                                    return;
                                }
                                else if ((result.indexOf("L") == 0)) {
                                    $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                                    top.location = '/index.aspx';
                                    return;
                                }
                            }
                        });
                       
                    }
                })
            }
           

        }
        function sendpmsgs() {
            var rows = $('#tt').datagrid('getSelections');
            if (rows == null || rows.length == 0) {
                $.messager.alert("提示", "请选择要设置的行！", "info");
                return;
            }
            if (rows) {
                $.messager.confirm('提示', '你确定要发送吗？', function (r) {
                    if (r) {
                        var uids = getphs(rows);
                        var date = $("#datetime").datebox('getValue');
                        var msg = "您" + date + "的数据还没有上传请及时上传数据，以免耽误工作！";
                        var title = "上传数据提醒";
                        $('#fm').form('submit', {
                            url: "../info/getinfo.ashx?action=addph&title=" + title + "&uid=" + uids + "&infocontent=" + msg,
                            onSubmit: function () {
                                return $(this).form('validate');
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $.messager.alert("提示", "恭喜您，信息发送成功", "info");
                                }
                                else {
                                    $.messager.alert("提示", result, "info");
                                    return;
                                }                                
                            }
                        });

                    }
                })
            }


        }
        function InitTree() {
            $('#pt').tree({
                width: '100%', //宽度                
                lines: true,
                //data: provincetree,   
                url: '../areainfo/GetArea.ashx', //请求数据的页面 
                method: 'post',
                queryParams: { "action": "querymyareauser" },
                onBeforeExpand: function (node) {
                    $("#pt").tree("options").queryParams = { "action": "queryyb9" };
                    $('#pt').tree('options').url = "../areainfo/GetArea.ashx?pid=" + node.id;
                },
                onClick: function (node) {
                    sprovince = scity = scounty = "";
                    if (node.text != "") {
                        var lv = $('#pt').tree("getLevel", node.target);
                        if (lv == 2) {
                            if (level > 3)
                                sprovince = node.text;
                            else if (level == 3)
                                scity = node.text;
                            else if (level == 2)
                                scounty = node.text;
                        }
                        else if (lv == 3) {
                            if (level > 3) {
                                scity = node.text;
                                sprovince = $('#pt').tree("getParent", node.target).text;
                            }
                            else if (level == 3) {
                                scounty = node.text
                                scity = $('#pt').tree("getParent", node.target).text;;
                            }
                        }
                        else if (lv == 4) {
                            if (level > 3) {
                                scounty = node.text;
                                var node1 = $('#pt').tree("getParent", node.target)
                                scity = node1.text;
                                sprovince = $('#pt').tree("getParent", node1.target).text;
                            }
                        }
                        reloadgrid();
                    }
                },
                onLoadSuccess: function (node, param) {
                    //reloadgrid();
                }
            });

        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="easyui-layout" style="width: 100%; height: 100%;" id="mycon">
        <div region="west" split="true" title="区域检索" style="width: 180px; overflow: scroll" id="west">
            <ul id="pt"></ul>
        </div>
        <div region="center" style="background: #eee; overflow: auto">
            <table id="tt"></table>
        </div>
    </div>

    <div id="tab_toolbar" style="padding: 4px;">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>
                <td style="text-align:left; padding-right: 15px">

                    <div style="padding:2px; ">
          用户名：   
           <input id="uname" class="easyui-validatebox" style="width:80px;"/> 负责人姓名：   
           <input id="utruename" class="easyui-validatebox" style="width:100px;"/> 
                            工作状态：
                        <select id="utype" class="easyui-combobox" name="utype" style="width:80px;">   
    <option value="0">全部</option>   
    <option value="1">未上传数据</option>   
    <option value="2">已上传数据</option>  
    
</select>  

                             日期：<input id="datetime" class="easyui-datebox" style="width:100px;"/>
        
                       
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reloadgrid()">查找</a>
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-bullet_red'" onclick="reloadgrid(1)">未上传数据</a>
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-bullet_green'" onclick="reloadgrid(2)">已上传数据</a>
                         <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-email_go'" onclick="sendmsgs()">发送植信通</a>
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-phone_go'" onclick="sendpmsgs()">发送手机短信</a>
                            </div>
            
                </td>
            </tr>
        </table>

    </div>
     <form id="fm" method="post" >           
        </form>
</asp:Content>
